home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: Float calculations
- Date: 01 Feb 1996 23:32:49 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Feb1163249@qcd.lanl.gov>
- References: <4eqssf$d9q@camelot.ccs.neu.edu>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: jason@ccs.neu.edu's message of 1 Feb 1996 17:22:23 GMT
-
- In article <4eqssf$d9q@camelot.ccs.neu.edu> jason@ccs.neu.edu (Jason
- Leatherman) writes:
- <snip>
- Hi,
-
- Check out the results I get when running this simple program on a
- Sparc/UNIX system, compiled with gcc:
-
- #include <stdio.h>
-
- void main()
- {
- float a, b;
-
- printf("%0.10f %0.10f %0.10f\n", 99974.0, 50.0, 99974.0/50.0);
-
- a = 99974.0;
- b = 50.0;
- printf("%0.10f %0.10f %0.10f\n", a, b, a/b);
- }
-
- The output is:
- 99974.0000000000 50.0000000000 1999.4800000000
- 99974.0000000000 50.0000000000 1999.4799804688
-
- Why do the divisions produce different results? This is probably some
- simple thing that I've forgotten, but I haven't figured it out yet. Does
- anyone know? Note that compiling with the -ffloat-store flag didn't make
- a difference.
-
- Because neither 99974.0 not 50.0 are floats.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-